unit uMemoEdit;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, cxContainer, cxEdit, dxSkinsCore, dxSkinBlack,
  dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee, dxSkinDarkRoom,
  dxSkinDarkSide, dxSkinDevExpressDarkStyle, dxSkinDevExpressStyle, dxSkinFoggy,
  dxSkinGlassOceans, dxSkinHighContrast, dxSkiniMaginary, dxSkinLilian,
  dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinOffice2010Black,
  dxSkinOffice2010Blue, dxSkinOffice2010Silver, dxSkinPumpkin, dxSkinSeven,
  dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus, dxSkinSilver,
  dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008, dxSkinTheAsphaltWorld,
  dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010, dxSkinWhiteprint,
  dxSkinXmas2008Blue, cxTextEdit, cxMemo, cxRichEdit, cxDBRichEdit, cxGroupBox,
  Vcl.Menus, Vcl.StdCtrls, cxButtons, Vcl.ActnList;

type
  TFrmMemoEdit = class(TForm)
    cxGroupBox1: TcxGroupBox;
    cxMemo1: TcxMemo;
    cxButton11: TcxButton;
    cxButton1: TcxButton;
    procedure cxButton11Click(Sender: TObject);
    procedure cxButton1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrmMemoEdit: TFrmMemoEdit;
  procedure FrmMemoEditShow(sList:TStringList;sCaption:string);overload;
  function FrmMemoEditShow(sMemo:string;sCaption:string=''):string;overload;
  function FrmMemoEditShow(sMemo:string;var IsOK:Boolean;sCaption:string=''):string;overload;

implementation

uses
  ucommFunction;

{$R *.dfm}

procedure FrmMemoEditShow(sList:TStringList;sCaption:string) ;
begin
  Application.CreateForm(TFrmMemoEdit, FrmMemoEdit);
  with FrmMemoEdit do
  begin
    if sCaption<>'' then
      Caption:=sCaption;
    cxMemo1.Lines.Text:=sList.Text;
    ShowModal;
    FreeAndNil(FrmMemoEdit);
  end;
end;

function FrmMemoEditShow(sMemo:string;var IsOK:Boolean;sCaption:string):string;
begin
  Application.CreateForm(TFrmMemoEdit, FrmMemoEdit);
  with FrmMemoEdit do
  begin
    if sCaption<>'' then
      Caption:=sCaption;
    cxMemo1.Lines.Text:=sMemo;
    if ShowModal=mrOK then
    begin
      Result:=cxMemo1.Lines.Text;
      IsOK:=True;
    end else
    begin
      Result:=sMemo;
      IsOK:=False;
    end;
  end;
  FreeAndNil(FrmMemoEdit);
end;

function FrmMemoEditShow(sMemo:string;sCaption:string=''):string;
begin
  Application.CreateForm(TFrmMemoEdit, FrmMemoEdit);
  with FrmMemoEdit do
  begin
    if sCaption<>'' then
      Caption:=sCaption;
    cxMemo1.Lines.Text:=sMemo;
    if ShowModal=mrOK then
      Result:=cxMemo1.Lines.Text
    else
      Result:=sMemo;
  end;
  FreeAndNil(FrmMemoEdit);
end;

procedure TFrmMemoEdit.cxButton11Click(Sender: TObject);
begin
  ModalResult:=mrOk;
end;

procedure TFrmMemoEdit.cxButton1Click(Sender: TObject);
begin
  ModalResult:=mrCancel;
end;

procedure TFrmMemoEdit.FormCreate(Sender: TObject);
begin
  pSetCaption(Self);
end;

end.
